package cn.shit;

import java.util.Arrays;

public class Multi {
    private static int[] an;
    private static int[] bn;
    private static int[] trim(int[] a) {
        int i;
        // 0 4 3 2 1 0 0 0
        for (i = a.length - 1; i>=0 ; i--) {
            if (a[i] != 0) {
                break;
            }
        }
        int[] aa = new int[i+1];
        for (; i>=0; i--) {
            aa[i] = a[i];
        }
        return aa;
    }
    private static void toArr(int a, int b) {
        int c = Math.max(a, b);
        int d = Math.min(a, b);
        a = c;
        b = d;
        int aa = a % 10;
        int[] ar = new int[10];
        int[] br = new int[10];
        int bb = b % 10;
        int i = 1;
        ar[0] = aa;
        br[0] = bb;
        a = a / 10;
        b = b / 10;
        while (a != 0 || b != 0) {
            aa = a % 10;
            bb = b % 10;
            a = a / 10;
            b = b / 10;
            ar[i] = aa;
            br[i] = bb;
            i++;
        }
//        System.out.println(Arrays.toString(trim(ar)));
//        System.out.println(Arrays.toString(trim(br)));
        an = trim(ar);
        bn = trim(br);
    }

    private static int multi() {
        int i = 0;// a是大的
        int j = 0;// b是小的
        int sum = 0;
        for (; i < bn.length; i++) {
            for (j = 0; j < an.length; j++) {
                sum += bn[i] * an[j] * (int)Math.pow(10, j + i);
            }
            //System.out.println("i= " + i + "sum= " + sum);
        }
        return sum;
        //System.out.println(Arrays.toString(level));
    }
    public static void main(String[] args) {
        toArr(10, 1);
        System.out.println(Arrays.toString(an) + "\n"+ Arrays.toString(bn));
        System.out.println(multi());
    }
    /*
    1  2  3  4  0
    3  4  5  6  7  0
    ----
    123
     17
   ------              21
                      14
                      7
                      861
                     123
  146
  123
  ---
  269


    0 4 3 2 1
    0 7 6 5 4 3
    -----

             24
             18
             12
             6

     */
}
